<section>
	<div class="page-header">
		<h2><?php echo $title; ?></h2>
	</div>
	
	<?php if ($permissions) : ?>
	<table class="zebra-striped">
		<thead>
			<tr>
				<th>Name</th>
				<th>URL</th>
				<th>Parent</th>
				<th width="80px">Actions</th>
			</tr>
		</thead>
		<tbody>
			<?php foreach ($permissions as $permission) : ?>
			<tr>
				<td><?php echo ($permission['parent_permission'] == 0 ? '' : '&mdash; &nbsp; ') . $permission['permission_name']; ?></td>
				<td><code><?php echo site_url($permission['permission_url']); ?></code></td>
				<td><?php echo $permission['parent_permission'] == 0 ? img('public/img/yes.png') : img('public/img/no.png'); ?></td>
				<td><?php echo anchor('users/edit_permission/' . $permission['permission_id'], 'Edit'); ?> &nbsp; <?php echo anchor('users/delete_permission/' . $permission['permission_id'], 'Delete', array('class' => 'delete')); ?></td>
			</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
	<?php echo $this->pagination->create_links(); ?>
	<?php else : ?>
	<p>No records found.</p>
	<?php endif; ?>
	
</section>

<script>

	$('table .delete').click(function() {
        
        del = $(this);
        
        buildModal({
            modalID: 'deletePermission',
            modalHeader: 'Delete Permission',
            modalBody: 'Are you sure that you want to delete this permission?',
            btnPrimaryText: 'Delete',
			ajaxUrl: del.attr('href')
        });
        
        return false;
    });

</script>